﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KP_CommonLibrary.KP_DataAccess;
using System.Data;
using Microsoft.ApplicationBlocks.Data;

namespace KEEPER_BRR_13dotNET.DataAccess
{
    public class DAL_KPDmLoaiHs : KP_DALListBase
    {
        public DAL_KPDmLoaiHs()
            : base("tblDmLoaiHs")
        {
        }
        public void Insert(DataRow row, DataTable tblGiayTo)
        {
            DAL_KPGiayToKemTheo dalGiayTo = new DAL_KPGiayToKemTheo();
            try
            {
                OpenConnection();
                BeginTransaction();
                Insert(Transaction, row);
                if (tblGiayTo != null)
                    dalGiayTo.Update(Transaction, tblGiayTo);
                Transaction.Commit();
                Transaction = null;
            }
            catch (Exception e)
            {
                if (Transaction != null)
                    Transaction.Rollback();
                Transaction = null;
                throw e;
            }
            finally
            {
                CloseConnection();

            }
        }
        public void Update(DataRow row, DataTable tblGiayTo)
        {
            DAL_KPGiayToKemTheo dalGiayTo = new DAL_KPGiayToKemTheo();
            try
            {
                OpenConnection();
                BeginTransaction();
                Update(Transaction, row);
                if (tblGiayTo != null)
                    dalGiayTo.Update(Transaction, tblGiayTo);
                Transaction.Commit();
                Transaction = null;
            }
            catch (Exception e)
            {
                if (Transaction != null)
                    Transaction.Rollback();
                Transaction = null;
                throw e;
            }
            finally
            {
                CloseConnection();

            }
        }
       
    }
}
